package com.example.redislock.utils;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName RedissonConfig
 * @Description
 * @Author zhangsw
 * @Date 2020/12/3 16:53
 * @Version 1.0
 */
@Configuration
public class RedissonConfig {

////    @Value("${spring.redis.host:0}")
//    private String host = "120.26.179.149";
//
////    @Value("${spring.redis.port:6379}")
//    private String port = "6379";
//
//    @Bean
//    public RedissonClient redissonClient(){
//        Config config = new Config();
//        config.useSingleServer().setAddress("redis://120.26.179.149:6379").setPassword("bd48777898a64ffd92b7");
//        RedissonClient redisson = Redisson.create(config);
//        return redisson;
//    }

    //    @Value("${spring.redis.host:0}")
    private String host = "120.26.179.149";

    //    @Value("${spring.redis.port:6379}")
    private String port = "6379";

    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        config.useSingleServer().setAddress("redis://120.26.179.149:6379").setPassword("bd48777898a64ffd92b7");
        RedissonClient redisson = Redisson.create(config);
        return redisson;
    }
}
